﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace csharpcore7_ch14_ConcurrencyAndAsynchrony
{
    class chapt14_3_2ReturnValue
    {
        static void _Main()
        {
            Task<int> primeNumberTask = Task.Run( () =>
                Enumerable.Range(2,3000000).Count(n =>
                Enumerable.Range(2,(int)Math.Sqrt(n)-1).All(i => n%i>0)));

            Console.WriteLine("Task running...");
            Console.WriteLine("The answer is " + primeNumberTask.Result);
        }
    }
}
